package ex02;

import java.util.Scanner;

import static java.lang.Math.sqrt;

public class Program {
    public static int sum(int num) {
        int sum = 0;
        for (int i = 0; i < 6; i++) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }

    public static boolean isPrime(int num) {
        boolean isPrime = true;
        if (num <= 1) {
            System.err.println("IllegalArgument");
            System.exit(-1);
        } else {
            for (int i = 2; ((i <= sqrt(num)) && isPrime); ++i) {
                if (num % i == 0) {
                    isPrime = false;
                }
            }
        }
        return isPrime;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int sum = 0;
        int counter = 0;
        while (num != 42) {
            sum = sum(num);
            if (isPrime(sum)) {
                ++counter;
            }
            num = scan.nextInt();
        }
        System.out.println("Count of coffee-request – " + counter);
    }
}
